<template>
  <div class="dashboard-editor-container">
    <div class="vanta-bg">
      <div ref="vantaRef" class="vanta" />
    </div>
    <div class="dashboard-editor-container-text">
      <div class="small">
        <div v-html="form.remark" />
      </div>
    </div>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
import * as THREE from "three";
import CLOUDS from "vanta/src/vanta.clouds";
import { getNoticeList } from "@/views/noticeList/api";

export default {
  name: "DashboardAdmin",
  data() {
    return {
      form: {},
      elementWidth: 0,
    };
  },
  computed: {
    ...mapGetters(["userInfo", "sidebar"]),
  },
  created() {
    this.getIntroduce();
  },
  mounted() {
    this.setCould();
  },
  beforeDestroy() {
    if (this.vantaEffect) {
      this.vantaEffect.destroy();
    }
  },
  methods: {
    getIntroduce() {
      getNoticeList()
        .then((res) => {
          if (!res) return;
          const { data } = res;
          this.loading = false;
          this.form = { ...data[0] };
        })
        .catch((err) => {
          console.log("TCL: getTableData -> err", err);
        });
    },
    setCould() {
      this.vantaEffect = CLOUDS({
        el: this.$refs.vantaRef,
        THREE: THREE,
        mouseControls: true,
        touchControls: true,
        gyroControls: false,
        minHeight: 200.0,
        minWidth: 200.0,
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.dashboard-editor-container {
  background-color: rgb(240, 242, 245);
  position: relative;
  display: flex;
  height: calc(100vh - 50px);
  box-sizing: border-box;
  align-items: center;
  justify-content: center;
  width: 100%;
  .vanta-bg {
    height: 100%;
    width: 100%;
    display: flex;
    justify-content: center;
  }
  .vanta {
    height: 100%;
    width: 100%;
  }

  &-text {
    color: #333;
    font-size: 50px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    flex: 1;
    z-index: 999;
    position: absolute;
    width: 80%;

    span {
      font-size: 50px;
    }

    .small {
      font-size: 20px;

      pre {
        width: 400px;
      }

      div {
        margin: 12px 0;
        line-height: 2;
      }
    }
  }
}
</style>
